package com.cc.crm.config;


import com.cc.crm.interceptor.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program:
 * @ClassName:
 * @description:
 * @author: zgc
 * @date:
 * @Version 1.0
 **/
@Configuration
public class MVCConfig implements WebMvcConfigurer {
    @Bean
    public Interceptor interceptor(){
        return new Interceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置要放行的资源
        String[] interceptors = {"/css/**","/js/**","/fonts/**","/picture/**","/user/**",""};
        //用于注册一个拦截器
        registry.addInterceptor(this.interceptor()).addPathPatterns("/**").excludePathPatterns(interceptors);
    }
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("crm");
    }
}
